package prj3.ui;

import java.awt.Color;

public class ColorPicker {


	int maxValue = 30;
	
	public ColorPicker(int maxValue){
		this.maxValue = maxValue;
	}
	
	public ColorPicker(){
		
	}
	
	public Color getColor(double v)
    {
        int b = 0;
        int g = 0;
        int r = 0;
        v = v / maxValue * 100;
        if (v == 0)
        {
            b = 225;
            g = 225;
            r = 225;
        } else if (v > 0 && v < 23)
        {
            b = 255;
            g = (int)(145 + (v * 5));
            r = 145;
        } else if (v >= 23 && v < 46)
        {

            b = (int)(255 - (v * 5) % 115);
            g = 255;
            r = 145;
        } else if (v >= 46 && v < 69)
        {
            b = 145;
            g = 255;
            r = (int)(145 + (v * 5) % 115);
        } else if (v >= 69 && v < 92)
        {
            b = 145;
            g = (int)(255 - (v * 5) % 115);
            r = 255;
        } else
        {
            b = (int)(145 - (v * 10) % 115);
            g = (int)(145 - (v * 10) % 115);
            r = 255;
        }
        
        if(r < 0){
            r = 0;
        }
        if(r > 255){
            r = 255;
        }
        if(g < 0){
            g = 0;
        }
        if(g > 255){
            g = 255;
        }
        if(b < 0){
            b = 0;
        }
        if(b > 255){
            b = 255;
        }
        return new Color(r, g, b);
    }
    
    public Color getRednessColor(double v){

        v = v/maxValue * 255;
        if(v > 255){
            v = 255;
        }
        if(v < 0){
            v = 0;
        }
        return new Color((int)v, 0, 0);
    }
}
